package com.lenovo.vod.player.callback;

import com.lenovo.vod.player.Engine;

import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.util.Log;

public class CompletionListener implements OnCompletionListener {
	private static final String TAG = "VODPlayer";
	private Engine mEngine;

	public CompletionListener(Engine engine) {
		mEngine = engine;
	}

	@Override
	public void onCompletion(MediaPlayer arg0) {
		Log.d(TAG, "onCompletion called");

		if (mEngine.getCurrentPosition() != 0
				&& mEngine.getCurrentPosition() == mEngine.getDuration()) {
			mEngine.playNext();
			return;
		}

		Log.d(TAG, "onCompletion abnormally");
	}
}
